<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8">
	<link rel="stylesheet" href="/Public/Center/css/ch-ui.admin.css">
	<link rel="stylesheet" href="/Public/Center/font/css/font-awesome.min.css">
	<script src="/Public/Center/js/jquery.js"></script>
    <script src="/Public/Center/js/jquery-1.12.4.js"></script>
    <script src="/Public/Center/js/jquery-ui.js"></script>
    <!--引入自定义css样式文件-->
    <link rel="stylesheet" href="/Public/Center/css/setconfig.css" />
    <script src="/Public/Center/js/layer.js"></script>
    <script type="text/javascript">
    <script type="text/javascript">
    	//0.常量定义区域
    	const MODULE = "/Center";
    	//1.检测是否存在主配置文件
    	<?php
 if($has_main_conf): ?>
    		var has_main_conf = true;
    	<?php
 else: ?>
    		var has_main_conf = false;
    	<?php
 endif; ?>
    </script>
    <script>
    	$(function(){
    		//初始化字典样式
    		$('input[type=checkbox]').each(function(){
				//联动span背景颜色
		    	if(this.checked){
		    		$(this).parent().css({
		    			'background':'gray',
						'color':'white',
		    		});
		    	}else{
		    		$(this).parent().css({
		    			'background':'white',
						'color':'black',
		    		});
		    	}    			
    		});
		    
    		//监听选中非选中状态
    		$('input[type=checkbox]').bind('change',function(){
		    	//联动span背景颜色
		    	if(this.checked){
		    		$(this).parent().css({
		    			'background':'gray',
						'color':'white',
		    		});
		    	}else{
		    		$(this).parent().css({
		    			'background':'white',
						'color':'black',
		    		});
		    	}
		    });
    		
    		//初始化鼠标样式
    		$('#dic2 span').bind({
		    	'mouseover':function(){
					$(this).css('cursor','pointer');    		
		    	},
		    	'mouseout':function(){
		    		$(this).css('cursor','');    		
		    	}
   			});
   			
   			//提交保存字典配置信息
   			$('#dic_commit').bind('click',function(){
   				layer.confirm('确定要提交保存吗?', {
					btn: ['是的','取消']
				}, function(){
					$('form').trigger('submit');
				}, function(){
				 	
				});
   			});
   			
   			//关闭窗口命令
   			$('input[name="frame_close"]').bind('click',function(){
   				var index = parent.layer.getFrameIndex(window.name);
				parent.layer.close(index);
   			});
    	});
    </script>
    <style>
    	.dir_list{
    		padding:6px;
			background:gray;
			color:white;
			font-size: 12px;;
			display: block;
			float: left;
			width:130px;
			border-radius: 3px;
			margin-left: 10px;
			margin-bottom: 10px;
			border:1px solid gray;
			text-align: center;
			height: 18px;
    	}
    </style>
</head>
<body>
	<div id="dic" style="padding-left:30px;">
		<h2 name='<?php echo $name;?>'><?php echo $dic['caption'];?>
		</h2>
		<div style="margin:10px auto;text-align: center;">
			<input id="dic_commit" style="background:red;border:0;" value="保存配置" type="button">
			<input name="frame_close" value="关闭窗口" type="button">
		</div>
		<form action="/Center/Index/saveDic" method="post">
		<div id="dic2">
		<!-- 添加字典name 隐藏域-->
		<input type="hidden" name="dic_name" value="<?php echo $name?>"/>
		<?php
 $dic_subitem = $dic['subitem']; foreach($dic_subitem as $k => $v): ?>
		<?php
 if($v['display']==true): ?>
		<span class='dir_list'><?php echo mb_substr($v['caption'],0,8,'utf-8');?><input checked='true' value='<?php echo $v['value'];?>' type='checkbox' name='dic_list[]'></span>
		<?php
 else: ?>
		<span class='dir_list'><?php echo mb_substr($v['caption'],0,8,'utf-8');?><input value='<?php echo $v['value'];?>' type='checkbox' name='dic_list[]'></span>
		<?php
 endif; ?>
		<?php
 endforeach; ?>
		</div>
	</div>
	</form>
	<script type="text/javascript">
		$( "#dic2" ).sortable();
    	$( "#dic2" ).disableSelection();
	</script>
</body>
</html>